package org.ft.fileConvert.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.ft.fileConvert.service.FileConvertService;
import org.ft.fileConvert.vo.ResultVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chentianzhong
 * @since 2022-08-10
 */
@Api(tags = "文件转化管理")
@RestController
@RequestMapping("/file/convert")
public class FileConvertController {

    @Resource
    private FileConvertService fileConvertService;

    @ApiOperation(value = "文件转化", httpMethod = "GET")
    @GetMapping("{id}")
    public ResultVo test(@PathVariable("id") String id){
        try{
            fileConvertService.convert(id);
            return ResultVo.success();
        }catch (Exception e){
            return ResultVo.fail("格式转换失败：" +e.getLocalizedMessage());
        }

    }

}
